#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 10;

bool st[N][N];
int n, m, x, y;
int ans;
int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};

void dfs(int x, int y, int cnt) {
    if (cnt == n * m)
    {
        ans ++ ;
        return ;
    }
    st[x][y] = true;
    for (int i = 0; i < 8; i ++ )
    {
        int a = x + dx[i], b = y + dy[i];
        if (a < 0 || a >= n || b < 0 || b >= m) continue;
        if (st[a][b]) continue;
        dfs(a, b, cnt + 1);
    }
    st[x][y] = false;
}

int main()
{
    int T;
    scanf("%d", &T);
    while (T -- )
    {
        ans = 0;
        memset(st, false, sizeof st);
        scanf("%d%d%d%d", &n, &m, &x, &y);
        dfs(x, y, 1);
        printf("%d\n", ans);
    }
    
    return 0;
}
